package com.djmw.mouse.repository;

import java.util.Date;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.djmw.mouse.entity.Position;

public interface PositionDao extends PagingAndSortingRepository<Position, Long>, JpaSpecificationExecutor<Position> {

	Page<Position> findByCompanyId(Long id, Pageable pageRequest);

	@Modifying
	@Query("update Position position set position.status = ?2 where position.id = ?1")
	void changeStatus(Long id, int status);

	@Modifying
	@Query("update Position position set position.refreshDate = ?2, position.closeDate = ?3 where position.id = ?1")
	void refresh(Long id, Date refreshDate, Date closeDate);
}
